<template>
  <div>
    <div class="main">
      <div class="name"><h3>欢迎光临vue开发的收银系统_水果店</h3></div>
      <div class="price">苹果10¥/斤,折扣 8折</div>
      <div class="count" @keydown.enter="Fn">
        请输入您要购买的斤数<input type="text" v-model.number="Jin" />
      </div>
      <div class="check">
        <button @click="Fn">结账买单</button>
      </div>
      <div class="menu">
        结账单:总价: {{ price }}¥元 折后价: {{ price1 }}¥元 省了:
        {{ price2 }}¥元
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      Jin: '',
      price: 0,
      price1: 0,
      price2: 0,
    }
  },
  methods: {
    Fn() {
      this.price = this.Jin * 10
      this.price1 = this.Jin * 8
      this.price2 = this.price - this.price1
      console.log('触发事件了')
    },
  },
}
</script>

<style>
.main {
  height: 5000px;
  position: relative;
}
.name {
  margin: 20px auto;
  width: 800px;
  height: 50px;
  text-align: center;
  line-height: 50px;
}
.price {
  margin: 20px auto;
  width: 800px;
  height: 50px;
  line-height: 50px;
  color: red;
  border: 1px solid #f0bb1e;
  text-align: center;
}
.count {
  margin: 20px auto;
  width: 800px;
  height: 50px;
  text-align: center;
  line-height: 50px;
  border: 1px solid #f0bb1e;
}
.check {
  margin: 20px auto;
  width: 800px;
  height: 50px;
  text-align: center;
  line-height: 50px;
  border: 1px solid #f0bb1e;
}
.menu {
  margin: 20px auto;
  width: 800px;
  height: 50px;
  text-align: center;
  line-height: 50px;
  border: 1px solid #f0bb1e;
}
</style>
